/* 
 * @author Mabel Xu
 */

import info.gridworld.actor.Bug;

/**
 * A <code>DancingBug</code> makes specified turns before each move. <br />
 */
public class DancingBug extends Bug
{
    private int[] turns;
    private int index;

    /**
     * Constructs a dancing bug that random dances
     * @param t array of ints indicating number of turns to make
     */
    public DancingBug(int[] t)
    {
        turns = t;
        index = 0;
    }

    /**
     * Makes correct number of turns, then moves 1 space.
     */
    public void act()
    {
    	for (int i = 0; i < turns[index]; i++)
    		this.turn();
    	index++;
    	super.act();
    	
    	// restart at beginning of array if run out of numbers to use
    	if (index == turns.length)
    		index = 0;
    }
}